package com.dream.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dream.able.MreplyMapper;
import com.dream.datasource.DBContextHolder;
import com.dream.pojo.Mreply;
import com.dream.pojo.MreplySon;
import com.dream.service.able.All_Service_able;


/*
 * 留言回复的业务类
 */
@Service("Mreply_Serviceimpl")
public class Mreply_Serviceimpl implements All_Service_able<MreplySon> {

	/*
	 * 留言回复表的DAO代理对象
	 */
	@Resource(name="mreplyMapper")
	private MreplyMapper mreply_mapper;
	
	/*
	 * (添加一条回复,传入，回复内容，用户id，留言id)
	 * @see com.dream.service.able.All_Service_able#insert(java.lang.String[])
	 */
	@Override
	public MreplySon insert(String... str) {
		//切换数据库，主库
		DBContextHolder.setDbType(DBContextHolder.master);
		//创建回复对象
		MreplySon mreply = new MreplySon();
		//插入回复内容
		mreply.setContext(str[0]);
		//插入用户id
		mreply.setUid(Integer.parseInt(str[1]));
		//插入留言id
		mreply.setMid(Integer.parseInt(str[2]));
		//插入时间
		mreply.setTime(new Date());
		//插入状态
		mreply.setState(1);
		//写入数据库
		return mreply_mapper.insertSelective(mreply)>0?mreply:null;
	}

	@Override
	public List<MreplySon> list() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public MreplySon getT(String... str) {
		// TODO Auto-generated method stub
		return null;
	}

}
